

			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
	
*-------------------------------------------------------------------------------
* base year 2012 
*-------------------------------------------------------------------------------

* data
use "data/inputs/MunicipioData_AD_Chavez.dta", clear

* save correlation with Chávez 2012
mat results = J(11, 2, 0)
local i = 1
foreach year of numlist 1958(5)1998 2000(6)2006 {
	cap cor share_presOFIC2012 share_presAD`year'
	if _rc == 0 {
	mat results[`i',1] = `year'
	mat results[`i',2] = `r(rho)'
	}
	else {
	cor share_presOFIC2012 share_presOFIC`year'
	mat results[`i',1] = `year'
	mat results[`i',2] = `r(rho)'
	}
	local i = `i' + 1
}

* use results
clear 
svmat results
rename results1 year
rename results2 cor2012

* line
su cor2012 if year == 1998
local xline = `r(mean)'

* graph
#delimit;
twoway (connected cor2012 year if year >= 1958 & year <= 2012, 
	    lcolor(black) mcolor(black) lwidth(medthick)
	    mlwidth(thick) mlcolor(white) msize(large))
		
	   (scatter cor2012 year if year == 1963, 
	    mcolor(black) 
	    mlwidth(thick) mlcolor(white) msize(large))
		
	   (scatter cor2012 year if year >= 1998 & year <= 2012, 
	    lcolor(black) mcolor(black) lwidth(medthick) msymbol(diamond)
	    mlwidth(thick) mlcolor(white) msize(large))
		
   	   (scatter cor2012 year if year == 1998, 
	    lcolor(black) mcolor(blue) msymbol(diamond)
	    mlwidth(thick) mlcolor(white) msize(large)),

		yline(0, lwidth(thick) lcolor(gs12))
		yline(`xline', lwidth(thin) lcolor(blue))
		graphregion(fcolor(white) lcolor(white) margin(zero))
        plotregion(fcolor(white) lstyle(none) lcolor(white) ilstyle(none))
        xsize(11) ysize(7.75)
		title("", size(large))
		ytitle("Correlation with 2012 Chávez vote share", color(black) size(large))			
		xtitle("")
        yscale()
		ylabel(-.2(.2)1, labsize(large) glcolor(white) angle(horizontal))
		xlabel(1958 "1958"
		1968 "1968"
		1978 "1978"
		1988 "1988"
		1998 "98  "
		2000 "  00"
		2006 "2006"
		2012 "2012", labsize(large))
		xscale( range(1958 2014))
        legend(order(2 "AD vs. Chávez 2012" 3 "Chávez vs. Chávez 2012") pos(8) ring(0) rows(2) region(lcolor(white)));		
graph export "figures/FigureD2a.pdf", replace;
#delimit cr



			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
	
*-------------------------------------------------------------------------------
* base year 1998 
*-------------------------------------------------------------------------------

* data
use "data/inputs/MunicipioData_AD_Chavez.dta", clear

* save correlation with Chávez 1998
mat results = J(11, 2, 0)
local i = 1
foreach year of numlist 1958(5)1993 2000(6)2012 {
	cap cor share_presOFIC1998 share_presAD`year'
	if _rc == 0 {
	mat results[`i',1] = `year'
	mat results[`i',2] = `r(rho)'
	}
	else {
	cor share_presOFIC1998 share_presOFIC`year'
	mat results[`i',1] = `year'
	mat results[`i',2] = `r(rho)'
	}
	local i = `i' + 1
}

* use results
clear 
svmat results
rename results1 year
rename results2 cor1998

* graph
#delimit;
twoway (connected cor1998 year if year >= 1958 & year <= 1993, 
	    lcolor(black) mcolor(black) lwidth(medthick)
	    mlwidth(thick) mlcolor(white) msize(large))
		
	   (connected cor1998 year if year >= 2000 & year <= 2012, 
	    lcolor(black) mcolor(black) lwidth(medthick) msymbol(diamond)
	    mlwidth(thick) mlcolor(white) msize(large)),

		yline(0, lwidth(thick) lcolor(gs12))		
		graphregion(fcolor(white) lcolor(white) margin(zero))
        plotregion(fcolor(white) lstyle(none) lcolor(white) ilstyle(none))
        xsize(11) ysize(7.75)		
		title("", size(large))		
		ytitle("Correlation with 1998 Chávez vote share", color(black) size(large))				
		xtitle("")
        yscale()
		ylabel(-.2(.2)1, labsize(large) glcolor(white) angle(horizontal))
		xlabel(1958 "1958"
		1968 "1968"
		1978 "1978"
		1988 "1988"
		1998 "98  "
		2000 "  00"
		2006 "2006"
		2012 "2012", labsize(large))
		xscale( range(1958 2014))
        legend(order(3 "AD vs. Chávez 1998" 4 "Chávez vs. Chávez 1998") pos(8) ring(0) rows(2) region(lcolor(white)));	
graph export "figures/FigureD2b.pdf", replace;
#delimit cr


* End
